/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 17655
 * Date: 2025-07-22
 * Time: 22:04
 */
public class test1 {
    public int lengthOfLongestSubstring(String s) {
        int n = s.length();
        int left=0,right=0;
        int ret = 0;
        int[] hash = new int[128];
        while (right<n){
            hash[s.charAt(right)]++;
            while(hash[s.charAt(right)]>1){
                hash[s.charAt(left)]--;
                left++;
            }
            ret = Math.max(ret,right-left+1);
            right++;
        }
        return ret;
    }
}
